﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using WpfApp_MvvmWindowBus.Base;

namespace WpfApp_MvvmWindowBus.ViewModel;

public class MainViewModel:INotifyPropertyChanged
{
    public Command BtnClickCommand { get; set; }

    private string? _value;

    public event PropertyChangedEventHandler? PropertyChanged;

    public string? Value
    {
        get { return _value; }
        set 
        { 
            _value = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
        }
    }


    public MainViewModel()
    {
        BtnClickCommand = new Command(obj => 
        {

            SubMainViewModel subMainViewModel = new SubMainViewModel();
            subMainViewModel.SubValue = this.Value;
            if (WindowProvider.ShowDialog("SubMainWindow", subMainViewModel))
            {
                this.Value = subMainViewModel.SubValue;
            }
            else 
            {
                
            }
        }, null);
    }

}
